//
// Created by tang on 2022/3/29.
//

#ifndef ADVANCEALARMSYSTEM_LOG_HPP
#define ADVANCEALARMSYSTEM_LOG_HPP

enum LogLevel {
    TRACE = 0,
    DEBUG,
    INFO,
    WARN,
    ERROR,
    CRITICAL,

    CNT
};

void log_message(LogLevel level, const char *fmt, ...);

// in release mode, TRACE and DEBUG log is ignored
#if defined(NDEBUG)
#define LOG_T(...)
#define LOG_D(...)
#else
#define LOG_T(fmt, ...) log_message(LogLevel::TRACE, fmt, ##__VA_ARGS__)
#define LOG_D(fmt, ...) log_message(LogLevel::DEBUG, fmt, ##__VA_ARGS__)
#endif

// 所有模式下都会生效的日志
#define LOG_I(fmt, ...) log_message(LogLevel::INFO, fmt, ##__VA_ARGS__)
#define LOG_W(fmt, ...) log_message(LogLevel::WARN, fmt, ##__VA_ARGS__)
#define LOG_E(fmt, ...) log_message(LogLevel::ERROR, fmt, ##__VA_ARGS__)
#define LOG_C(fmt, ...) log_message(LogLevel::CRITICAL, fmt, ##__VA_ARGS__)

#endif //ADVANCEALARMSYSTEM_LOG_HPP
